Conversation
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
6ca2e36 to
3b19d07
Compare
|
|
||
| /// @dev Returns true if admin or agent, false otherwise. | ||
| function isAdminOrAgent(address account) public view virtual returns (bool) { | ||
| return isAdmin(account) || isAgent(account); |
There was a problem hiding this comment.
Question about the original ERC7984Rwa contract: should the admin role be the DEFAULT_ADMIN_ROLE or another admin dedicated to agents?
Let's say I extend this contract and I add another role called PAUSER, so that I want the pauser to be managed by a PAUSER_ADMIN role. However, by leaving the current admin as DEFAULT_ADMIN_ROLE, it would unexpectedly have authority over PAUSER's and PAUSER_ADMIN. In that scenario I think we want to keep admins for agents separated from admins for pausers.
| } | ||
|
|
||
| /// @inheritdoc IComplianceModuleConfidential | ||
| function isModule() public pure override returns (bytes4) { |
There was a problem hiding this comment.
I think we can drop the override since this comes from an interface
| function isModule() public pure override returns (bytes4) { | |
| function isModule() public pure returns (bytes4) { |
There was a problem hiding this comment.
I honestly prefer to have an override when possible. Why do we have the policy to not?
There was a problem hiding this comment.
🧹 Nitpick comments (4)
contracts/interfaces/IERC7984Rwa.sol (1)
106-122: Consider consolidating duplicate interface definitions.
IERC7984RwaComplianceModulehas identical method signatures toIComplianceModuleConfidentialdefined incontracts/interfaces/IComplianceModuleConfidential.sol. Having two identical interfaces can lead to maintenance burden and potential divergence.Consider either:
- Having
IERC7984RwaComplianceModuleextendIComplianceModuleConfidential- Using
IComplianceModuleConfidentialdirectly throughout the codebase🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@contracts/interfaces/IERC7984Rwa.sol` around lines 106 - 122, The two interfaces IERC7984RwaComplianceModule and IComplianceModuleConfidential define identical signatures (isModule, isCompliantTransfer, postTransfer, onInstall, onUninstall); consolidate them by replacing the duplicate IERC7984RwaComplianceModule with either an extension or direct reuse of IComplianceModuleConfidential: update IERC7984RwaComplianceModule to "extend IComplianceModuleConfidential" or remove IERC7984RwaComplianceModule and update all references to use IComplianceModuleConfidential, ensuring method names isModule, isCompliantTransfer, postTransfer, onInstall, and onUninstall remain available where referenced.contracts/token/ERC7984/extensions/ERC7984RwaModularCompliance.sol (1)
91-97: Consider explicit return for unsupported module types.When
moduleTypeis neitherForceTransfernorStandard, the function returns an uninitializedinstalled(implicitlyfalse). While this is safe, an explicitreturn falseor a revert would make the behavior clearer.♻️ Optional: Make the fallback explicit
function _isModuleInstalled( ComplianceModuleType moduleType, address module ) internal view virtual returns (bool installed) { if (moduleType == ComplianceModuleType.ForceTransfer) return _forceTransferComplianceModules.contains(module); if (moduleType == ComplianceModuleType.Standard) return _complianceModules.contains(module); + return false; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@contracts/token/ERC7984/extensions/ERC7984RwaModularCompliance.sol` around lines 91 - 97, The _isModuleInstalled function currently falls through without an explicit return for unsupported ComplianceModuleType values; update _isModuleInstalled to explicitly return false (or revert if you prefer stricter behavior) when moduleType is not ForceTransfer or Standard so the function never relies on an uninitialized installed value—locate the _isModuleInstalled method and add a final explicit `return false` (or a revert with a clear message) after the existing conditionals.test/token/ERC7984/extensions/ERC7984RwaModularCompliance.test.ts (2)
16-34: Consolidate setup using the existing fixture helper.Setup is duplicated between
fixtureandbeforeEach; usingfixture()directly inbeforeEachwill reduce drift and keep tests easier to maintain.♻️ Proposed refactor
- beforeEach(async function () { - const [admin, agent1, agent2, holder, recipient, anyone] = await ethers.getSigners(); - const token = ( - await ethers.deployContract('$ERC7984RwaModularComplianceMock', ['name', 'symbol', 'uri', admin]) - ).connect(anyone) as $ERC7984RwaModularCompliance; - await token.connect(admin).addAgent(agent1); - const complianceModule = await ethers.deployContract('$ComplianceModuleConfidentialMock'); - - Object.assign(this, { - token, - complianceModule, - admin, - agent1, - agent2, - recipient, - holder, - anyone, - }); - }); + beforeEach(async function () { + Object.assign(this, await fixture()); + });Also applies to: 37-55
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/token/ERC7984/extensions/ERC7984RwaModularCompliance.test.ts` around lines 16 - 34, The test defines a local async fixture function that duplicates setup already performed in beforeEach; replace the duplicated setup by calling the shared fixture helper directly in beforeEach and remove the local fixture function to avoid drift — update references to the returned objects (token, holder, complianceModule, admin, agent1, agent2, recipient, anyone) so they are obtained from the existing fixture call (e.g., const { token, holder, complianceModule, admin, agent1, agent2, recipient, anyone } = await fixture(); or similar), and ensure uses of addAgent and contract connections are performed inside the central fixture/home fixture helper instead of the local fixture in ERC7984RwaModularCompliance.test.ts.
57-57: Removeasynckeyword fromdescribecallbacks.At Lines 57, 69, 112, and 161,
describeusesasync function. Mocha executesdescribecallbacks synchronously during suite loading; async callbacks are ignored, and tests registered after anawaitmay not be registered. Move async setup to hooks (before,beforeEach) instead.Proposed fix
- describe('support module', async function () { + describe('support module', function () {- describe('install module', async function () { + describe('install module', function () {- describe('uninstall module', async function () { + describe('uninstall module', function () {- describe('check compliance on transfer', async function () { + describe('check compliance on transfer', function () {Also applies to: 69-69, 112-112, 161-161
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/token/ERC7984/extensions/ERC7984RwaModularCompliance.test.ts` at line 57, Remove the async keyword from the describe callbacks (e.g., the describe('support module', ...) and the other describe blocks flagged) because Mocha runs describe blocks synchronously; any async/await inside them prevents proper test registration. Move any asynchronous setup/await logic into before or beforeEach hooks (create async functions like before(async () => { ... }) or beforeEach(async () => { ... })) and keep the describe callback plain function() so all it does is declare nested it/describe calls synchronously; update any references to setup variables to be assigned in those hooks instead of inside the describe body.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@contracts/interfaces/IERC7984Rwa.sol`:
- Around line 106-122: The two interfaces IERC7984RwaComplianceModule and
IComplianceModuleConfidential define identical signatures (isModule,
isCompliantTransfer, postTransfer, onInstall, onUninstall); consolidate them by
replacing the duplicate IERC7984RwaComplianceModule with either an extension or
direct reuse of IComplianceModuleConfidential: update
IERC7984RwaComplianceModule to "extend IComplianceModuleConfidential" or remove
IERC7984RwaComplianceModule and update all references to use
IComplianceModuleConfidential, ensuring method names isModule,
isCompliantTransfer, postTransfer, onInstall, and onUninstall remain available
where referenced.
In `@contracts/token/ERC7984/extensions/ERC7984RwaModularCompliance.sol`:
- Around line 91-97: The _isModuleInstalled function currently falls through
without an explicit return for unsupported ComplianceModuleType values; update
_isModuleInstalled to explicitly return false (or revert if you prefer stricter
behavior) when moduleType is not ForceTransfer or Standard so the function never
relies on an uninitialized installed value—locate the _isModuleInstalled method
and add a final explicit `return false` (or a revert with a clear message) after
the existing conditionals.
In `@test/token/ERC7984/extensions/ERC7984RwaModularCompliance.test.ts`:
- Around line 16-34: The test defines a local async fixture function that
duplicates setup already performed in beforeEach; replace the duplicated setup
by calling the shared fixture helper directly in beforeEach and remove the local
fixture function to avoid drift — update references to the returned objects
(token, holder, complianceModule, admin, agent1, agent2, recipient, anyone) so
they are obtained from the existing fixture call (e.g., const { token, holder,
complianceModule, admin, agent1, agent2, recipient, anyone } = await fixture();
or similar), and ensure uses of addAgent and contract connections are performed
inside the central fixture/home fixture helper instead of the local fixture in
ERC7984RwaModularCompliance.test.ts.
- Line 57: Remove the async keyword from the describe callbacks (e.g., the
describe('support module', ...) and the other describe blocks flagged) because
Mocha runs describe blocks synchronously; any async/await inside them prevents
proper test registration. Move any asynchronous setup/await logic into before or
beforeEach hooks (create async functions like before(async () => { ... }) or
beforeEach(async () => { ... })) and keep the describe callback plain function()
so all it does is declare nested it/describe calls synchronously; update any
references to setup variables to be assigned in those hooks instead of inside
the describe body.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
.changeset/wet-results-doubt.mdcontracts/finance/compliance/ComplianceModuleConfidential.solcontracts/interfaces/IComplianceModuleConfidential.solcontracts/interfaces/IERC7984Rwa.solcontracts/mocks/token/ComplianceModuleConfidentialMock.solcontracts/mocks/token/ERC7984Mock.solcontracts/mocks/token/ERC7984RwaModularComplianceMock.solcontracts/token/ERC7984/extensions/ERC7984Rwa.solcontracts/token/ERC7984/extensions/ERC7984RwaModularCompliance.soltest/helpers/interface.tstest/token/ERC7984/ERC7984.test.tstest/token/ERC7984/extensions/ERC7984RwaModularCompliance.test.ts
…nceModuleConfidential`
|
Replaced by #332 |
Summary by CodeRabbit
Release Notes
New Features
Tests